home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93b.txt
/
000105_icon-group-sender _Wed May 19 18:19:10 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-06-16
|
2KB
Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Thu, 20 May 1993 08:00:43 MST
Received: by owl.cs.arizona.edu; Thu, 20 May 1993 08:00:41 MST
Date: 19 May 93 18:19:10 GMT
From: agate!howland.reston.ans.net!ux1.cso.uiuc.edu!uchinews!ellis!goer@ucbvax.Berkeley.EDU (Richard L. Goerwitz)
Organization: University of Chicago
Subject: Re: A bug? Or a feature?
Message-Id: <1993May19.181910.14699@midway.uchicago.edu>
References: <12743@sun13.scri.fsu.edu>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
John Nall writes that the Icon manual says:
>
> X1 op:= X2
> "performs the operation X1 op X2 and assigns the result to X1
>
> ...To wit: it actually:
>
> "performs the operation X1 op (X2) and assigns the result to X1"
I see what you mean. The problem is with how you define X1 and X2.
Here's the scoup: Think of X1 and X2 as expression 1 and expression 2.
How do we group expressions? By operator precedence and newlines. What
is the precedence of <:=, for example? It is the same as any assignment
operator's. What is the precedence of >, say? It is the same as that
of any comparison operator.
Now we can answer the question of how the following expression groups:
> i <:= j > k
Since comparison has a higher precedence than assignment, we group (j > k)
as one expression. Hence the correct grouping of the entire assignment
expression is:
i <:= (j > k)
Ergo i is expression 1, and (j > k) is expression 2. The augmented assign-
ment operator adds the result of expression 2 to expression 1, and assigns
the result to expression 1 (if, in fact, expression 1 produces a variable).
So the Icon book is, in fact, correct, using its own definitions. op:= is
not a macro; it is a regular assignment operator. You just have to figure
out how the surrounding expressions group.
Note:
What your comments indicate is that the Icon book's explanation, while cor-
rect, may not be intuitive to everyone. Good question.
--
-Richard L. Goerwitz goer%midway@uchicago.bitnet
goer@midway.uchicago.edu rutgers!oddjob!ellis!goer